left-round-bracketright-round-bracket
Type
operator
Summary
Syntax
(<expression>)
Description
Use parentheses ( ) to group operands together in order to control the order operations are performed in, or to make the structure of a complex expression clearer.
When LiveCode evaluates an expression, operations enclosed within parentheses are performed first. If parentheses are nested, the expression within the innermost set of parentheses is evaluated first.
For example, the sin function is evaluated before the /
operator, so the sin of 1/4
means "take the sine of one, then divide
by four". To obtain the sine of 1/4, use parentheses to force the
division to be done first, as in this expression: the sin of (1/4)
.
Even when they are not needed to change operator precedence, parentheses are useful in making complex expressions more readable. For example,
(quantity * priceEach) + (shippingCost * weight)
evaluates to the same number as
quantity * priceEach + shippingCost * weight
But the first example is easier to understand, because the parentheses break down the expression logically for the reader.
Parentheses in expressions must be used in pairs, each ( with a matching ). Use of unmatched parentheses will cause a compile error.
Parameters
Name | Type | Description |
---|---|---|
expression | Any LiveCode expression. |
Examples
local quantity, priceEach, shippingCost
get (quantity * priceEach) + shippingCost
("a" is within field 1) or ("b" is within field 2)
23 * ((4 / 17) + 60) + (- 7)
Related
control structure: function
glossary: matched, operand, operation, operator, group, expression, control structure, evaluate, compile error
keyword: left-square-bracketright-square-bracket
operator: plus, dash, asterisk, slash
Compatibility and Support
Introduced
LiveCode 1.0
OS
mac
windows
linux
ios
android
Platforms
desktop
server
mobile